package com.newlink.building.common_base.utils

import android.content.Context


/**
 * Created by xiaodong on 2022/11/30.
 */
object Base_DeviceUtils {

    fun getAppVersion(context: Context): Int {
        var version = -1
        try {
            val manager = context.packageManager
            val packageInfo = manager.getPackageInfo(context.packageName, 0)
            version = packageInfo.versionCode
            return version
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return version
    }

    fun getVersionName(context: Context): String {
        var version = ""
        try {
            val manager = context.packageManager
            val packageInfo = manager.getPackageInfo(context.packageName, 0)
            version = packageInfo.versionName
            return version
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return version
    }


}
